import java.util.Vector;


class P10935_39643 {

	public static void main(String[] args) {
		while (true) {
			
			int n = Integer.parseInt(readLn());
			
			if (n == 0) break;
			
			process(n);
			
		}
	}
	
	private static void process(int n) {
		Vector v = new Vector();
		for (int k = 1; k <= n; k++) {
			v.addElement(new Integer(k));
		}
		
		int[] array = new int[n];
		int length = 0;
		
		Object remaining;
		
		while (v.size() > 1) {
			array[length] = ((Integer)v.elementAt(0)).intValue();
			v.removeElementAt(0);
			remaining = v.elementAt(0);
			v.addElement(remaining);
			v.removeElementAt(0);
			length++;
		}
		
		StringBuffer sb = new StringBuffer("Discarded cards: ");
		
		for (int k = 0; k < length; k++) {
			sb.append(array[k]);
			
			if (k + 1 != length) sb.append(", ");
		}
		System.out.println(sb.toString().trim());
		System.out.println("Remaining card: " + v.elementAt(0));
		
	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}
	
}
